package com.showsu.editor.session;

import com.showsu.editor.enums.ResultCode;
import com.showsu.editor.exception.BaseErrorInfoInterface;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * @Author: William
 * @Description: 会话异常类
 * @Date: Created in 10:53 上午 2024/9/20
 * @Modified By:
 */
@Data
@Slf4j
public class SessionException extends RuntimeException {

    private Integer errorCode;
    private String errorMsg;

    public SessionException() {
        this.errorCode = ResultCode.UN_AUTHORIZED.getCode();
        this.errorMsg = ResultCode.UN_AUTHORIZED.getMessage();
    }

    public SessionException(BaseErrorInfoInterface errorInfoInterface) {
        this.errorCode = errorInfoInterface.getResultCode();
        this.errorMsg = errorInfoInterface.getResultMsg();
    }

    public SessionException(BaseErrorInfoInterface errorInfoInterface, Throwable cause) {
        this.errorCode = errorInfoInterface.getResultCode();
        this.errorMsg = errorInfoInterface.getResultMsg();
    }

    public SessionException(String errorMsg) {
        super(errorMsg);
        this.errorMsg = errorMsg;
    }

    public SessionException(Integer errorCode, String errorMsg) {
        this.errorCode = errorCode;
        this.errorMsg = errorMsg;
    }
}
